import java.util.ArrayList;
import java.util.List;

public class FractionAddition {

    public static void main(String[] args) {
        FractionAddition fractionAddition = new FractionAddition();
        System.out.println(fractionAddition.fractionAddition("10/9-4/1+10/9-9/10+4/3"));
    }

    public String fractionAddition(String expression) {
        List<Integer> son = new ArrayList<>();
        List<Integer> parent = new ArrayList<>();
        int sub = 1;
        char[] chars = expression.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            if (chars[i] < '0' || chars[i] > '9') continue;
            char c = i == 0 ? '.' : chars[i - 1];
            int index = i;
            String s = chars[i] + "";
            while (i != chars.length - 1 && chars[i + 1] >= '0' && chars[i + 1] <= '9') {
                s += chars[i + 1];
                ++i;
            }
            int temp = Integer.parseInt(s);
            if (index == 0 || c != '/') {
                if (c == '-') temp = (-temp);
                son.add(temp);
            } else {
                parent.add(temp);
                sub *= temp;
            }
        }
        int sum = 0;
        for (int i = 0; i < son.size(); i++) {
            sum += son.get(i) * (sub / parent.get(i));
        }
        if (sum == 0) return 0 + "/" + 1;
        boolean flag = false;
        if (sum < 0) {
            flag = true;
            sum = (-sum);
        }
        int target = gcd(sub, sum);
        sub /= target;
        sum /= target;
        if (flag) sum = (-sum);
        return sum + "/" + sub;
    }

    public int gcd(int x, int y) {
        return y == 0 ? x : gcd(y, x % y);
    }
}
